﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;

namespace Listocky
{
    public class QAModel : INotifyPropertyChanged
    {
        static string DefaultQ = "No question";
        static string DefaultA = "No answer";

        public QAModel()
        {
            Question = DefaultQ;
            Answer = DefaultA;
            Hint = "";
        }
        private string question;
        public String Question
        {
            get { return question; }
            set { question = value; OnPropertyChanged("Question"); }
        }

        private string answer;
        public String Answer
        {
            get { return answer; }
            set { answer = value; OnPropertyChanged("Answer"); }
        }

        private string hint;
        public String Hint
        {
            get { return hint; }
            set { hint = value; OnPropertyChanged("Hint"); }
        }

        public delegate void ContentChanged();

        public event PropertyChangedEventHandler PropertyChanged;
        public event ContentChanged _contentChanged;

        private void OnPropertyChanged(string prop)
        {
            if (_contentChanged != null)
                _contentChanged();
            if (PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs(prop));
        }

        public void Load(System.IO.StreamReader reader)
        {
            Question = reader.ReadLine();
            Answer = reader.ReadLine();
            Hint = reader.ReadLine();
        }
        public void Save(System.IO.StreamWriter writer)
        {
            writer.WriteLine(Question);
            writer.WriteLine(Answer);
            writer.WriteLine(Hint);
        }
    }
}
